const CompanyModel = require("../model/CompanyModel")

const CompanyService = {
    getList:async () => {
        //联系role集合查询
        return await CompanyModel.find()
    },
    addList:async (body) => {
        // return CompanyModel.create(body)
        for(let i of body){
            await CompanyModel.findOneAndUpdate({
                title:i.title
            },{
                $set:i
            },{
                upsert:true
            })
        }
        return []
    },
    deleteList:async(id) => {
        //删除所有包含classid的数据
        return await CompanyModel.deleteMany({class:id})
    },
    updateList:async(id,data) => {
        return await CompanyModel.findByIdAndUpdate(id,data)
    }
}
module.exports = CompanyService